package com.fysports.web.controller.system;

import com.jfinal.json.Json;
import com.fysports.web.controller.AbstractBaseController;
import com.fysports.web.kit.commons.PathBizKit;
import com.fysports.web.kit.tree.ITreeBuilder;
import com.fysports.web.kit.tree.SystemMenuTreeBuilder;
import com.fysports.web.model.system.SystemMenu;
import com.fysports.web.module.core.DefaultModuleBuilder;
import com.fysports.web.module.core.IModuleFactory;

import java.util.List;


/**
 * 菜单管理Controller
 * Date : 14-8-5 下午12:53
 * Project : JdmData_WebServer
 */
public class ManagerMenuTreeController extends AbstractBaseController {
    private ITreeBuilder<SystemMenu> builder = new SystemMenuTreeBuilder();
    IModuleFactory moduleFactory = new DefaultModuleBuilder();


    //默认菜单树(全部)
    public void index() {
        setAttr("list", SystemMenu.dao.search(SystemMenu.COL_LIVEFLAG, "1"));
        moduleFactory.create(this);
        execute();
        List<SystemMenu> list = SystemMenu.dao.getChilds("1");
        setAttr("menujson", Json.getJson().toJson(builder.builderTree(list)));
        render(PathBizKit.getPageAdminPath("system/menu/tree/_menu_tree.ftl"));
    }

}
